package com.thoughtworks;

/**
 * Triangle Exercises
 */

public class Triangle {

    /**
     * Easiest exercise ever
     * Print one asterisk to the console.
     * Example:
     */
    public static void printAsterisk() {
        System.out.print("*");
    }

    /**
     * Draw a horizontal line
     * Given a number n, print n asterisks on one line.
     * Example when n=8:
     * *******
     *
     * @param n of asterisk
     */

    public static void printLineAsterisk(int n) {
        for (int i = 0; i < n; i++) {
            printAsterisk();
        }
    }

    /**
     * Draw a vertical line
     * Given a number n, print n lines, each with one asterisks
     * Example when n=3:
     *
     * @param n of asterisk
     */
    public static void printVLineAsterisk(int n) {
        for (int i = 0; i < n; i++) {
            printAsterisk();
            System.out.println();
        }
    }

    /**
     * Draw a right triangle
     * Given a number n, print n lines, each with one more asterisk than the last (i.e. one on the first line, two on the second,etc.)
     * Example when n=3:
     * <p/>
     * *
     * **
     *
     * @param n of asterisk
     */

    public static void printTriangle(int n) {
        for (int i = 1; i <= n; i++) {
            printLineAsterisk(i);
            System.out.println();
        }
    }

    public static void main(String[] args) {

        printAsterisk();
        System.out.println();
        printLineAsterisk(8);
        System.out.println();
        printVLineAsterisk(3);
        System.out.println();
        printTriangle(7);
    }
}
